Skip to main content

Data Types

Numeric

Data TypeDescription
TINYINTSmall integer, range: -128 to 127 or 0 to 255 (unsigned).
SMALLINTLarger range than TINYINT, range: -32,768 to 32,767.
MEDIUMINTMedium integer, range: -8,388,608 to 8,388,607.
INT or INTEGERStandard integer, range: -2,147,483,648 to 2,147,483,647.
BIGINTLarge integer, range: -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807.
DECIMALFixed-point numbers with exact precision, e.g., salaries or monetary values.
FLOATFloating-point numbers (approximate precision).
DOUBLELarger floating-point numbers than FLOAT (also approximate).
BITUsed for storing bit values, e.g., binary data like 1010.

In Terms of Capacity

TINYINT < SMALLINT < MEDIUMINT < INT < BIGINT

In Terms of Precision Handling

FLOAT < DOUBLE < DECIMAL

String

Data TypeDescription
CHARFixed-length string, up to 255 characters.
VARCHARVariable-length string, up to 65,535 characters (depending on row size).
TINYTEXTShort text, up to 255 characters.
MEDIUMTEXTMedium-length text, up to 16,777,215 characters.
TEXTLong text data, used for large strings (e.g., articles or comments).
LONGTEXTVery long text, up to 4,294,967,295 characters.
BLOBBinary Large Object, used for binary data like images or files.
ENUMString object with predefined values, e.g., 'small', 'medium', 'large'.
SETString object storing multiple predefined values (comma-separated).

In Short

CHAR → VARCHAR → TINYTEXT → TEXT → MEDIUMTEXT → LONGTEXT

Date and Time

Data TypeDescription
YEARStores the year in 4-digit format, e.g., 2024.
TIMEStores time in HH:MM:SS format.
DATEStores date in YYYY-MM-DD format.
DATETIMEStores both date and time in YYYY-MM-DD HH:MM:SS format.
TIMESTAMPSimilar to DATETIME, but it automatically updates with the current date/time when modified.